package com.opgea.crm.web.security;
;

/*
public class CrmAuthenticationSuccessHandler  extends SimpleUrlAuthenticationSuccessHandler {
	 protected final Log logger = LogFactory.getLog(CrmAuthenticationSuccessHandler.class);

	    private RequestCache requestCache = new HttpSessionRequestCache();

	    @Override
	    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
	            Authentication authentication) throws ServletException, IOException {
	       
	    	SavedRequest savedRequest = requestCache.getRequest(request, response);
	    	//SINCE WE ARE ALWAYS GOING TO DEFAULT PAGE BEHAVIOR WILL NOT BE USED.
//	        if (savedRequest == null) {
//	            super.onAuthenticationSuccess(request, response, authentication);
//	            return;
//	        }
//
//	        if (isAlwaysUseDefaultTargetUrl() || StringUtils.hasText(request.getParameter(getTargetUrlParameter()))) {
//	            requestCache.removeRequest(request, response);
//	            super.onAuthenticationSuccess(request, response, authentication);
//
//	            return;
//	        }

	        clearAuthenticationAttributes(request);

	        // Use the DefaultSavedRequest URL
	        
	        String targetUrl = savedRequest!=null?savedRequest.getRedirectUrl():"/";
	        logger.debug("Target Url: " + targetUrl);
	        Writer out=null;
	        try {
				HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(response);
				out = responseWrapper.getWriter();
				out.write("{success:true, targetUrl : \'" + targetUrl + "\'}");
			} finally {
				if (out != null) {
					out.close();
				}
			}
	        
	        
	        
	        //getRedirectStrategy().sendRedirect(request, response, targetUrl);
	    }

	    public void setRequestCache(RequestCache requestCache) {
	        this.requestCache = requestCache;
	    }

}
*/